//************************************************************************
/// <copyrigth>2024-2025 Corporation.All Rights Reserved</copyrigth>
/// <author>tangyingzhong</author>
/// <contact>tangyz114987@outlook.com</contact>
/// <version>v1.0.0</version>
/// <describe>
/// Cross-Platform sqlite
///</describe>
/// <date>2024/3/9</date>
///***********************************************************************
#ifndef SQLITE_H
#define SQLITE_H

#include <map>
#include <vector>
#include <string>
#include "ModuleLoader/ModuleConfig.h"

namespace SystemTool
{
    class CLASS_ITEM SqliteDB
    {
    public:
        // Construct the db
        SqliteDB();

        // Destruct the db
        ~SqliteDB();

    private:
        // Copy construct
        SqliteDB(const SqliteDB &other) = delete;

        // Assignment
        SqliteDB& operator=(const SqliteDB &other) = delete;

    public:
        // Connect to db with tiemout
        bool ConnectTo(std::string strDbFilePath);

        // Disconnect from db
        void Disconnect();

        // Is connected to db
        bool IsConnected();

        // Reconnect to the db
        void Reconnect();

        // Excute the single sql(add/delete/update/search)
        bool ExcuteSql(std::string strSql, std::vector<std::vector<std::string>> *pSearchRetTable = nullptr);

        // Excute the add/delete/update by transaction
        bool ExcuteByTrans(std::vector<std::string> &vSqlTable);

        // Excute the searching by transaction
        bool SearchByTrans(std::map<std::string, std::vector<std::string>> &SqlMap);

    private:
        // Poco session
        void* m_pSession;
    };
}

#endif // SQLITE_H
